<template>
	<view class="coupon">
		<view class="c-header">
			<text :class="index==1?'active':''" @click="changetab(1)">可用优惠券</text>
			<text :class="index==2?'active':''" @click="changetab(2)">不可用优惠券</text>
		</view>

		<view class="content">
			<!-- 空白页 -->
			<view v-if="empty===true" class="empty">
				<image src="/static/img/1/5.png" mode="aspectFit"></image>

				<view class="empty-tips">无相关的优惠券</view>
			</view>

			<view v-else class="list">
				<view class="yes" v-if="index == 1">


					<view class="item" v-for="l in list.availableMemberCoupon" :key="l.couponCoding">
						<image src="/static/img/1/101.png" mode="aspectFit"></image>

						<view class="fit">
							<image src="/static/img/1/2.png" mode="aspectFit" class="money"></image>
							<view class="info">
								<text class="title">满{{l.startAmount}}减{{l.reduceAmount}}</text>
								<text class="detail">{{l.iTypeName}}</text>
								<text class="detail">适用平台：{{l.couponScope}}</text>
								<text class="detail">有效期至：{{l.expireEndDate}}</text>
							</view>
							<view class="circle" @click="toprepage(l)">
								<view class="inner">
									<text class="text">去使用</text>
								</view>
								<view class="cover"></view>
							</view>
						</view>
					</view>
					
				</view>

				<view class="no" v-if="index == 2">
					<view class="item" v-for="l in list.unavailableMemberCoupon" :key="l.couponId">
						<image src="/static/img/1/19.png" mode="aspectFit"></image>
						<view class="fit">
							<image src="/static/img/1/2.png" mode="aspectFit" class="money"></image>
							<view class="info">
								<text class="title">满{{l.startAmount}}减{{l.reduceAmount}}</text>
								<text class="detail">{{l.iTypeName}}</text>
								<text class="detail">适用平台：{{l.couponScope}}</text>
								<text class="detail">有效期至：{{l.expireEndDate}}</text>
							</view>
							<view class="circle">
								<image src="/static/img/1/96.png" mode="aspectFit"></image>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		components: {

		},
		data() {
			return {
				empty: false,
				index: 1,
				list: [],
				couponData: {}
			}
		},
		async onLoad() {
			this.couponData = this.$SysCache.get("couponData")
			let orderdata = []
			orderdata.push({
				"iShopId": -1,
				"data": {
					"payableAmounts": 15,
					"pageIndex": 1,
					"pageSize": 1000,
					"iFilterType": 1,
					orderDetail: this.couponData.oOrderDetails,

				}


			})
			let postactivity = {
				"postActivityId": '',
				"promotionAmount": 0,
				"promotionAmountId": 0,
				"orderDetailData": orderdata
			}

			this.$Request.post(this.$api.httpApi.order.getAvailableCoupon + "&token=" + this.$SysCache.get('token'), {
				"param": postactivity
			}).then(res => {
				this.list = res.data[-2]

			})
		},
		methods: {
			changetab(str) {
				this.index = str
			},
			toprepage(item){
				this.$api.prePage().coupon = item;
				uni.navigateBack()
			}
		},
		onNavigationBarButtonTap() {
			uni.navigateTo({
				url: `/pages/coupon/explain`
			})
		}


	}
</script>

<style lang="scss">
	page {
		padding-bottom: 120upx;
		background: #f5f5f5;
	}

	.c-header {
		top: 44px;
		left: 0;
		right: 0;
		position: fixed;
		height: 80upx;
		padding: 20upx 70upx 0 70upx;
		display: flex;
		justify-content: space-between;
		align-items: center;
		background: #000;
		z-index: 888;

		text {
			display: inline-flex;
			height: 100%;
			font-size: 25upx;
			font-family: Microsoft YaHei;
			font-weight: 400;
			color: #fff;
		}

		.active {
			color: #4DC897;
			border-bottom: 4upx solid #4DC897;
		}
	}

	.coupon {
		position: absolute;
		top: 44px;
		left: 0;
		right: 0;

		.empty {
			position: fixed;
			left: 0;
			top: 0;
			width: 100%;
			height: 100vh;
			padding-bottom: 173upx;
			display: flex;
			justify-content: center;
			flex-direction: column;
			align-items: center;

			image {
				width: 249upx;
				height: 248upx;
				margin-bottom: 10upx;
			}

			.empty-tips {
				display: flex;
				font-size: 31upx;
				font-family: Microsoft YaHei;
				font-weight: 400;
				color: rgba(102, 102, 102, 1);

			}
		}

		.list {
			padding: 23upx 21upx;

			.item {
				position: relative;
				margin-bottom: 21upx;
			}

			image {
				width: 100%;
				height: 200upx;
				display: block;
			}

			.fit {
				position: absolute;
				top: 0;
				left: 0;
				right: 0;
				bottom: 0;
				display: flex;
				justify-content: space-between;
				align-items: center;
				padding: 25upx 45upx;

				.money {
					width: 180upx;
					height: 144upx;
				}

				.info {
					height: 100%;

					.title {
						width: 200upx;
						height: 50upx;
						background: rgba(240, 64, 111, 0);
						border: 2upx solid rgba(255, 255, 255, 1);
						font-size: 27upx;
						font-family: Microsoft YaHei;
						font-weight: 400;
						color: rgba(255, 255, 255, 1);
						display: flex;
						justify-content: center;
						align-items: center;
						margin-bottom: 19upx;
					}

					.detail {
						display: flex;
						justify-content: flex-start;
						font-size: 19upx;
						font-family: Microsoft YaHei;
						font-weight: 400;
						color: rgba(255, 255, 255, 1);
						line-height: 30upx;
					}
				}

				.circle {
					width: 131upx;
					height: 131upx;
					position: relative;
					// background:rgba(255,255,255,1);
					// opacity:0.2;
					border-radius: 50%;
					display: flex;
					justify-content: center;
					align-items: center;

					.inner {
						width: 98upx;
						height: 98upx;
						background: rgba(4, 0, 0, 1);
						border-radius: 50%;
						display: flex;
						justify-content: center;
						align-items: center;
						z-index: 2;

						.text {
							font-size: 23upx;
							font-family: Microsoft YaHei;
							font-weight: 400;
							color: rgba(255, 255, 255, 1);
						}
					}

					.cover {
						position: absolute;
						top: 0;
						left: 0;
						right: 0;
						bottom: 0;
						background: rgba(255, 255, 255, 1);
						opacity: 0.2;
						border-radius: 50%;
						z-index: 1;
					}
				}
			}
		}
	}
</style>
